Skip to content

Conversation

@andrewbrook
Copy link

Discussion

"App version" will be used by the telemetry package to distinguish deployments of web applications. This is the most basic implementation, requiring developers to explicitly specify the version information.

Testing

Manual testing, unit testing

API Changes

N/A

@andrewbrook andrewbrook requested review from a team as code owners November 17, 2025 18:27
@changeset-bot
Copy link

changeset-bot bot commented Nov 17, 2025

⚠️ No Changeset found

Latest commit: 07158a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link

Summary of Changes

Hello @andrewbrook, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the telemetry package by providing a mechanism for developers to explicitly define their application's version. This version information is crucial for distinguishing different deployments of web applications within telemetry data, improving the clarity and utility of collected metrics. The change involves updating the core telemetry API, its underlying service, and associated documentation and tests to support this new configuration option.

Highlights

  • New appVersion Option: Introduced an optional appVersion property to the TelemetryOptions interface, allowing developers to explicitly set the application's version for telemetry data.
  • Telemetry Log Attribute: Telemetry logs will now include an app.version attribute. If appVersion is not explicitly provided, it will default to 'unset'.
  • Telemetry Service Configuration: The TelemetryService has been updated to store its configuration options, including the new appVersion, enabling consistent access to these settings.
  • Documentation and Tests: Comprehensive documentation for the appVersion property has been added, and new test cases ensure that the explicit appVersion is correctly captured in telemetry logs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an appVersion option for telemetry, which is a valuable addition for distinguishing application deployments. The changes are well-structured, covering API definitions, documentation, implementation, and tests. My review focuses on improving correctness for edge cases, strengthening encapsulation, and enhancing the robustness of the tests. Overall, this is a solid contribution.

import { LoggerProvider } from '@opentelemetry/sdk-logs';

export class TelemetryService implements Telemetry, _FirebaseService {
_options?: TelemetryOptions;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The backing field _options for the options property is currently public. To ensure proper encapsulation and prevent direct modification from outside the class, it should be made private. The public options getter and setter are the intended way to interact with this property.

Suggested change
_options?: TelemetryOptions;
private _options?: TelemetryOptions;

Comment on lines +98 to +100
if ((telemetry as TelemetryService).options?.appVersion) {
appVersion = (telemetry as TelemetryService).options!.appVersion!;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current check for appVersion uses a truthiness check, which will incorrectly handle an empty string ('') as a version. If a user explicitly provides an empty string, it will be treated as falsy, and the appVersion will default to 'unset'. To correctly handle all string values, including empty ones, you should check for null or undefined instead.

Suggested change
if ((telemetry as TelemetryService).options?.appVersion) {
appVersion = (telemetry as TelemetryService).options!.appVersion!;
}
if ((telemetry as TelemetryService).options?.appVersion != null) {
appVersion = (telemetry as TelemetryService).options.appVersion;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty string should map to unset

Comment on lines 232 to 237
const telemetry = {
...fakeTelemetry,
options: {
appVersion: '1.0.0'
}
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test creates a plain object that structurally mimics a TelemetryService instance. This approach is not type-safe and relies on the internal implementation detail of captureError casting the telemetry object. A more robust and type-safe approach would be to instantiate TelemetryService directly, which will make the test less brittle to future refactoring.

Suggested change
const telemetry = {
...fakeTelemetry,
options: {
appVersion: '1.0.0'
}
};
const telemetry = new TelemetryService(
fakeTelemetry.app,
fakeTelemetry.loggerProvider
);
telemetry.options = {
appVersion: '1.0.0'
};

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 17, 2025

Size Report 1

Affected Products

  • @firebase/ai

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?67.4 kB? (?)
    main?71.7 kB? (?)
    module?67.4 kB? (?)
  • @firebase/analytics

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?21.6 kB? (?)
    main?22.8 kB? (?)
    module?21.6 kB? (?)
  • @firebase/analytics-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?2.57 kB? (?)
    main?3.01 kB? (?)
    module?2.57 kB? (?)
  • @firebase/api-documenter

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?3.95 kB? (?)
  • @firebase/app

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?19.6 kB? (?)
    main?20.5 kB? (?)
    module?19.6 kB? (?)
    react-native?20.5 kB? (?)
  • @firebase/app-check

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?26.4 kB? (?)
    main?27.3 kB? (?)
    module?26.4 kB? (?)
  • @firebase/app-check-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?2.27 kB? (?)
    main?2.74 kB? (?)
    module?2.27 kB? (?)
  • @firebase/app-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?5.25 kB? (?)
    lite?4.06 kB? (?)
    main?5.82 kB? (?)
    module?5.25 kB? (?)
  • @firebase/auth

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?188 kB? (?)
    cordova?161 kB? (?)
    main?144 kB? (?)
    module?188 kB? (?)
    react-native?161 kB? (?)
  • @firebase/auth-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?20.0 kB? (?)
    main?22.1 kB? (?)
    module?20.0 kB? (?)
  • @firebase/auth-cordova

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?161 kB? (?)
    module?161 kB? (?)
  • @firebase/auth-web-extension

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?139 kB? (?)
    main?156 kB? (?)
    module?139 kB? (?)
  • @firebase/auth/internal

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?198 kB? (?)
    main?169 kB? (?)
    module?198 kB? (?)
  • @firebase/component

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?6.38 kB? (?)
    main?6.72 kB? (?)
    module?6.38 kB? (?)
  • @firebase/data-connect

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?21.5 kB? (?)
    main?23.7 kB? (?)
    module?21.5 kB? (?)
  • @firebase/database

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?249 kB? (?)
    main?254 kB? (?)
    module?249 kB? (?)
  • @firebase/database-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?18.2 kB? (?)
    main?18.9 kB? (?)
    module?18.2 kB? (?)
  • @firebase/database-compat/standalone

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?366 kB? (?)
  • @firebase/firestore

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?391 kB? (?)
    main?611 kB? (?)
    module?391 kB? (?)
    react-native?392 kB? (?)
  • @firebase/firestore-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?20.3 kB? (?)
    main?20.7 kB? (?)
    module?20.3 kB? (?)
    react-native?20.3 kB? (?)
  • @firebase/firestore-lite

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?115 kB? (?)
    main?158 kB? (?)
    module?115 kB? (?)
    react-native?116 kB? (?)
  • @firebase/functions

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?14.2 kB? (?)
    main?14.7 kB? (?)
    module?14.2 kB? (?)
  • @firebase/functions-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?1.73 kB? (?)
    main?2.07 kB? (?)
    module?1.73 kB? (?)
  • @firebase/installations

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?17.6 kB? (?)
    main?18.2 kB? (?)
    module?17.6 kB? (?)
  • @firebase/installations-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?945 B? (?)
    main?1.27 kB? (?)
    module?945 B? (?)
  • @firebase/logger

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?3.78 kB? (?)
    module?3.21 kB? (?)
  • @firebase/messaging

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?21.5 kB? (?)
    main?22.0 kB? (?)
    module?21.5 kB? (?)
  • @firebase/messaging-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?2.08 kB? (?)
    main?2.43 kB? (?)
    module?2.08 kB? (?)
  • @firebase/messaging-sw

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?23.3 kB? (?)
    module?22.8 kB? (?)
  • @firebase/performance

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?31.2 kB? (?)
    main?31.7 kB? (?)
    module?31.2 kB? (?)
  • @firebase/performance-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?1.10 kB? (?)
    main?1.42 kB? (?)
    module?1.10 kB? (?)
  • @firebase/remote-config

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?39.0 kB? (?)
    main?40.2 kB? (?)
    module?39.0 kB? (?)
  • @firebase/remote-config-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?1.85 kB? (?)
    main?2.18 kB? (?)
    module?1.85 kB? (?)
  • @firebase/rules-unit-testing

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?11.7 kB? (?)
  • @firebase/storage

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?58.3 kB? (?)
    main?59.8 kB? (?)
    module?58.3 kB? (?)
  • @firebase/storage-compat

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?5.66 kB? (?)
    main?6.04 kB? (?)
    module?5.66 kB? (?)
  • @firebase/telemetry

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?6.84 kB? (?)
    main?6.94 kB? (?)
    module?6.84 kB? (?)
  • @firebase/util

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?29.1 kB? (?)
    main?35.5 kB? (?)
    module?29.1 kB? (?)
  • @firebase/webchannel-wrapper

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?38 B? (?)
  • @firebase/webchannel-wrapper/bloom-blob

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?11.3 kB? (?)
    main?11.3 kB? (?)
    module?11.3 kB? (?)
  • @firebase/webchannel-wrapper/webchannel-blob

    TypeBase (26aadfd)Merge (248b83b)Diff
    browser?40.9 kB? (?)
    main?40.9 kB? (?)
    module?40.9 kB? (?)
  • bundle

    46 size changes

    TypeBase (26aadfd)Merge (248b83b)Diff
    analytics (logEvent)?44.1 kB? (?)
    app-check (CustomProvider)?37.3 kB? (?)
    app-check (ReCaptchaEnterpriseProvider)?39.6 kB? (?)
    app-check (ReCaptchaV3Provider)?39.6 kB? (?)
    auth (Anonymous)?74.8 kB? (?)
    auth (EmailAndPassword)?84.5 kB? (?)
    auth (GoogleFBTwitterGitHubPopup)?106 kB? (?)
    auth (GooglePopup)?98.2 kB? (?)
    auth (GoogleRedirect)?98.3 kB? (?)
    auth (Phone)?91.8 kB? (?)
    database (Append to a list of data)?154 kB? (?)
    database (Filtering data)?153 kB? (?)
    database (Listen for child events)?169 kB? (?)
    database (Listen for value events + Detach listeners)?169 kB? (?)
    database (Listen for value events)?169 kB? (?)
    database (Read data once)?168 kB? (?)
    database (Save data as transactions)?171 kB? (?)
    database (Sort data)?154 kB? (?)
    database (Write data)?153 kB? (?)
    firestore (CSI Auto Indexing Disable and Delete)?286 kB? (?)
    firestore (CSI Auto Indexing Enable)?286 kB? (?)
    firestore (Persistence)?318 kB? (?)
    firestore (Query Cursors)?257 kB? (?)
    firestore (Query)?255 kB? (?)
    firestore (Read data once)?245 kB? (?)
    firestore (Read Write w Persistence)?338 kB? (?)
    firestore (Realtime updates)?245 kB? (?)
    firestore (Transaction)?223 kB? (?)
    firestore (Write data)?225 kB? (?)
    firestore-lite (Query Cursors)?110 kB? (?)
    firestore-lite (Query)?106 kB? (?)
    firestore-lite (Read data once)?81.7 kB? (?)
    firestore-lite (Transaction)?107 kB? (?)
    firestore-lite (Write data)?91.2 kB? (?)
    functions (call)?38.8 kB? (?)
    messaging (send + receive)?46.4 kB? (?)
    performance (trace)?62.1 kB? (?)
    remote-config (getAndFetch)?59.5 kB? (?)
    storage (getBytes)?46.6 kB? (?)
    storage (getDownloadURL)?48.7 kB? (?)
    storage (getMetadata)?48.2 kB? (?)
    storage (list + listAll)?47.6 kB? (?)
    storage (updateMetadata)?48.4 kB? (?)
    storage (uploadBytes)?53.3 kB? (?)
    storage (uploadBytesResumable)?63.2 kB? (?)
    storage (uploadString)?53.5 kB? (?)

  • firebase

    33 size changes

    TypeBase (26aadfd)Merge (248b83b)Diff
    firebase-ai.js?52.8 kB? (?)
    firebase-analytics-compat.js?25.4 kB? (?)
    firebase-analytics.js?29.4 kB? (?)
    firebase-app-check-compat.js?22.8 kB? (?)
    firebase-app-check.js?25.0 kB? (?)
    firebase-app-compat.js?31.6 kB? (?)
    firebase-app.js?103 kB? (?)
    firebase-auth-compat.js?142 kB? (?)
    firebase-auth-cordova.js?139 kB? (?)
    firebase-auth-web-extension.js?122 kB? (?)
    firebase-auth.js?159 kB? (?)
    firebase-compat.js?809 kB? (?)
    firebase-data-connect.js?22.6 kB? (?)
    firebase-database-compat.js?168 kB? (?)
    firebase-database.js?192 kB? (?)
    firebase-firestore-compat.js?348 kB? (?)
    firebase-firestore-lite.js?138 kB? (?)
    firebase-firestore.js?454 kB? (?)
    firebase-functions-compat.js?14.8 kB? (?)
    firebase-functions.js?19.5 kB? (?)
    firebase-installations-compat.js?12.7 kB? (?)
    firebase-installations.js?15.0 kB? (?)
    firebase-messaging-compat.js?36.3 kB? (?)
    firebase-messaging-sw.js?29.3 kB? (?)
    firebase-messaging.js?28.6 kB? (?)
    firebase-performance-compat.js?40.3 kB? (?)
    firebase-performance-standalone-compat.js?105 kB? (?)
    firebase-performance.js?45.6 kB? (?)
    firebase-remote-config-compat.js?38.7 kB? (?)
    firebase-remote-config.js?43.5 kB? (?)
    firebase-storage-compat.js?44.2 kB? (?)
    firebase-storage.js?51.1 kB? (?)
    firebase-telemetry.js?73.8 kB? (?)

  • functions

    TypeBase (26aadfd)Merge (248b83b)Diff
    main?46 B? (?)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/Z1xr9XjxrJ.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 17, 2025

Size Analysis Report 1

Affected Products

  • @firebase/telemetry

    • captureError

      Size

      TypeBase (26aadfd)Merge (248b83b)Diff
      size3.99 kB4.11 kB+112 B (+2.8%)
      size-with-ext-deps54.9 kB55.0 kB+112 B (+0.2%)
    • flush

      Size

      TypeBase (26aadfd)Merge (248b83b)Diff
      size3.39 kB3.45 kB+66 B (+1.9%)
      size-with-ext-deps53.6 kB53.7 kB+66 B (+0.1%)
    • getTelemetry

      Size

      TypeBase (26aadfd)Merge (248b83b)Diff
      size3.40 kB3.49 kB+94 B (+2.8%)
      size-with-ext-deps60.7 kB60.8 kB+94 B (+0.2%)
    • nextOnRequestError

      Size

      TypeBase (26aadfd)Merge (248b83b)Diff
      size4.34 kB4.48 kB+140 B (+3.2%)
      size-with-ext-deps62.3 kB62.4 kB+140 B (+0.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/xuiiYC2S4W.html

@andrewbrook andrewbrook merged commit 836a427 into telemetry Nov 17, 2025
45 checks passed
@andrewbrook andrewbrook deleted the telemetry1 branch November 17, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants